import pytest
from tools.parse_week_ranges import parse_week_ranges


@pytest.mark.parametrize("input_str, expected", [
    ("2-7,9-13", [2,3,4,5,6,7,9,10,11,12,13]),
    ("14", [14]),
    ("2-16,18", [2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18]),
    ("2-16", list(range(2,17))),
    ("2-3,6-16", [2,3] + list(range(6,17))),
    ("17-20", [17,18,19,20])
], ids=[
    "连续区间+非连续区间",
    "单周次",
    "完整区间+独立周次",
    "完整连续区间",
    "多段非连续区间",
    "跨周区间"
])
def test_parse_week_ranges(input_str, expected):
    """验证不同格式的周次字符串解析"""
    result = parse_week_ranges(input_str)
    assert result == expected, f"解析失败：输入({input_str})期望得到{expected}，实际得到{result}"
